﻿<%@ Page Title="" Language="C#" MasterPageFile="~/clerks/ClerkMaster.Master" AutoEventWireup="true"
    CodeBehind="ProcessDetail.aspx.cs" Inherits="LogicUniversity.clerks.ProcessDetail" %>

<%@ PreviousPageType VirtualPath="~/clerks/RequisitionList.aspx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <form id="form1" runat="server">
    <div class="row-fluid">
        <div class="span8 well">
            <div class="row-fluid">
                <div class="span4">
                    <asp:Label ID="lblDeptName" runat="server" Text="Dept Name : "></asp:Label>
                    <asp:Label ID="DepartmentName" runat="server"></asp:Label>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span4">
                    <asp:Label ID="lblDate" runat="server" Text="Date : "></asp:Label>
                    <asp:Label ID="date" runat="server"></asp:Label>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span4">
                    <asp:Label ID="lblCollectPoint" runat="server" Text="Collection Point : "></asp:Label>
                    <asp:Label ID="collectionPoint" runat="server"></asp:Label>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span4">
                    <asp:Label ID="lblRepName" runat="server" Text="Rep Name : "></asp:Label>
                    <asp:Label ID="repName" runat="server"></asp:Label>
                </div>
            </div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span8">
            <div class="accordion" id="actual">
                <div class="accordion-group">
                    <div class="accordion-heading">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#actual" href="#ActualView">
                            Actual Request </a>
                    </div>
                    <div id="ActualView" class="accordion-body collapse">
                        <div class="accordion-inner">
                            <div class="row-fluid">
                                <div class="span8">
                                    <asp:GridView CssClass="table table-hover" GridLines="None" ID="grdRequisitionDetail"
                                        AutoGenerateColumns="false" runat="server" Width="100%">
                                        <Columns>
                                            <asp:BoundField DataField="Item_Description" HeaderText="Description" />
                                            <asp:BoundField DataField="Needed" HeaderText="Needed Qty" />
                                        </Columns>
                                    </asp:GridView>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span8">
            <div class="accordion" id="outstanding">
                <div class="accordion-group">
                    <div class="accordion-heading">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#outstanding" href="#OutstandingView">
                            Outstanding Requests </a>
                    </div>
                    <div class="accordion-body collapse" id="OutstandingView">
                        <div class="accordion-inner">
                            <asp:Label ID="lblOutMsg" runat="server"></asp:Label>
                            <div class="span8">
                                <asp:GridView GridLines="None" CssClass="table table-hover" ID="grdOutstanding" runat="server"
                                    AutoGenerateColumns="false">
                                    <Columns>
                                        <asp:BoundField DataField="Item_Description" HeaderText="Description" />
                                        <asp:BoundField DataField="Needed" HeaderText="Outstanding Quantity" />
                                    </Columns>
                                </asp:GridView>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span8">
            <div class="accordion" id="Div1">
                <div class="accordion-group">
                    <div class="accordion-heading">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#outstanding" href="#TotalView">
                            Total Requests </a>
                    </div>
                    <div class="accordion-body collapse" id="TotalView">
                        <div class="accordion-inner">
                            <div class="span8">
                                <div class="row-fluid">
                                <div class="span12">
                                <asp:GridView CssClass="table table-hover" GridLines="None" ID="grdRequisitionToAdd" runat="server" AutoGenerateColumns="false">
                                    <Columns>
                                        <asp:BoundField DataField="Item_Description" HeaderText="Description" />
                                        <asp:BoundField DataField="Needed" HeaderText="Needed" />
                                        <asp:BoundField DataField="Balance" HeaderText="Balance" />
                                        <asp:TemplateField HeaderText="Actual">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtActual"  required="required" runat="server" 
                                                    Text='<%#Bind("Actual_Quanty") %>' Height="20px" Width="104px" />
                                                <asp:Label ID="lblMsg" ForeColor="Red" runat="server"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="Item_Code" Visible="false" />
                                    </Columns>
                                </asp:GridView>
                                </div>
                                </div>
                                <div class="row-fluid">
                                    <div class="span12">
                                        <asp:Button CssClass="btn btn-primary" ID="btnAddToRetrieval" runat="server" Text="Add To Retrieval List" OnClick="btnAddToRetrieval_Click" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $('#content_grdRequisitionToAdd tr input:text').change(function () {
                var requestQty = $(this).parents('tr').children('td').eq(1).text();
                var balance = $(this).parents('tr').children('td').eq(2).text();

                var retrieved = $(this).parents('tr').children('td').find('input:text').val();

                if (parseInt(retrieved) > parseInt(requestQty) || parseInt(retrieved) > parseInt(balance)) {
                    alert('Actual Quantity cannot be more than either needed or balance.');
                }
            });
        </script>
        <script type="text/javascript">
            $('#content_btnAddToRetrieval').click(function () {
                $('#content_grdRequisitionToAdd tr').each(function () {
                    var state = true;
                    var requestQty = $(this).children('td').eq(1).text();
                    var balance = $(this).children('td').eq(2).text();

                    var retrieved = $(this).children('td').find('input:text').val();

                    if (parseInt(retrieved) > parseInt(requestQty) || parseInt(retrieved) > parseInt(balance)) {
                        alert('Actual Quantity cannot be more than either needed or balance.');
                        state = false;
                    }

                    return state;
                });
            });
        </script>
    </form>
</asp:Content>
